package com.zb.util;

import com.zb.entity.base.JsonCommon;

/**
 * @author pengyu
 * @Title 订单系统常量类
 * @date 2016-01-26
 */
public class OmsConstant
{
	public final static int Success = 1;
	public final static int Failed = 0;
	public final static JsonCommon<String> jsonSuccess = new JsonCommon<String>("200", "success");
	public final static JsonCommon<String> jsonFail = new JsonCommon<String>(ErrorCodeEnum.RedisQueryNull.value, "exception");
	public final static JsonCommon<String> jsonRedisQueryNull = new JsonCommon<String>(ErrorCodeEnum.RedisQueryNull.value, "redis query null");
	public final static JsonCommon<String> jsonEv3cExecFail = new JsonCommon<String>(ErrorCodeEnum.MessageExecError.value, "ev3c exec fail");
	public final static String sysCode = "120161012";
	public final static String sysCodeDuplicateInstructionException = "13000001"; // DuplicateInstructionException

	public enum ChargerTypeDB implements EnumCodeValue
	{
		AC("1", "直流"),
		DC("2", "交流");

		private String value = null;
		private String desc = null;

		ChargerTypeDB(String v, String desc)
		{
			this.value = v;
			this.desc = desc;
		}

		@Override
		public String value()
		{
			return this.value;
		}

		@Override
		public String desc()
		{
			return this.desc;
		}
	}

	public enum BoolValue implements EnumCodeValue
	{
		No("0", "否"),
		Yes("1", "是");

		private String value = null;
		private String desc = null;

		BoolValue(String v, String desc)
		{
			this.value = v;
			this.desc = desc;
		}

		@Override
		public String value()
		{
			return this.value;
		}

		@Override
		public String desc()
		{
			return this.desc;
		}
	}

	public final static class ChargingPaymentMeans
	{
		//	费用类型:1：预约费用；2：充电费用；3：充电服务费,0为尚未分配类型的费用
		public final static int Undefined = 0;
		public final static int Reservation = 1;
		public final static int Charging = 2;
		public final static int ChargeService = 3;
	}

	public final static class PaymentMode
	{
		//	收费模式：0：按时间收费，1：按次数收费
		public final static int ByTime = 0;
		public final static int ByFrequency = 1;
	}

	public final static class BespeakStatus
	{
		public final static int Reserving = 1;
		public final static int Reserved = 2;
		public final static int ReservationCancelling = 3;;
		public final static int ReservationCancelled = 4;
		public final static int Charged = 5;
				/*
		 *  0：预约中
			1：已预约
			2：主动取消预约中
			3：被动取消预约中
			4  已取消预约
			5：此单最终取消预约变为空闲；
			6：此单最终为充电。
		 * */
	}

	public final static class ChargerType
	{
		public static final String DC = "1";
		public static final String AC= "0";

	}

	public final static class ChargerPortStatus
	{
		public final static int Available = 0;
		public final static int Reserved = 1;
		public final static int Charging = 2;
		public final static int Down = 3;
		public final static int InUse = 4;
		public final static int ReadingCard = 5;
		public final static int Offline = 8;
		//	0: 空闲;1: 预约;2 充电; 3 故障;4:占用中（针对双枪单充等情况）;5 刷卡中  8:离线
	}


	public final static class ChargeType
	{
		public final static String TillFull = "0";
		public final static String ByElectricity = "1";
		public final static String ByMoney = "2";
		public final static String ByTime = "3";
		//		0：自动充满 			1：按预设电量充电 			2：按金额充电 			3：按充电时间充电
	}

	public final static class ChargingBillStatus
	{
		public final static int NotifyCharging = 0;
		public final static int Charging = 1;
		public final static int ChargedIncomplete = 2;
		public final static int NotifyStopCharging = 3;
		public final static int ChargingComplete = 4;
		public final static int BillGenerated = 5;
		public final static int Paid = 6;
		public final static int Refund = 7;
		public final static int ChargingFailed = 8;

		//0 开启充电：已下发指令未回复；
		//1 充电中 ：已确认桩回复；
		//2 电充满未结束：如未拔枪则是此状态；
		//3 关闭充电：已下发指令 ；
		//4 充电结束 ：桩回复充电结束 ；
		//5 已生成账单；
		//6 已结算 ；
		//7 已退款 ；
		//8 充电失败。
	}

	public final static class ChargerStartupType
	{
		public final static int Immediately = 0;
		public final static int InAdvance = 1;

		//启动方式：0：即时充电；1：定时启动
	}

	public final static class PayStatus
	{
		public final static int OfflineUnpaid = 0;
		public final static int OfflinePaid = 1;
		public final static int OnlineUnpaid = 2;
		public final static int OnlinePaid = 3;

		//0 线下未结算,1 线下已结算，2 线上未结算 ，3 线上已结算
	}

	public final static class CardStateEnum
	{
		public final static int InActive = 0;
		public final static int Active = 1;
		public final static int Freeze = 2;
		public final static int Loss = 3;
		public final static int Cancelled = 4;
		public final static int NotExist = 10;
		public final static int InValidType = 11;

		//		状态码 -- 0未激活，1激活，2冻结，3挂失，4 注销；10 不存在，11 卡类型错误
	}

	public final static class CardTypeEnum
	{
		public final static String OnlineApp = "08";
		public final static String Cash = "06";
		public final static String Identity = "05";
		public final static String OnlineCompany = "08";

		//卡类型：08 线上卡，06 现金卡，05 身份认证卡
	}

	public enum SuccessCodeEnum implements EnumCodeValue
	{
		SuccessCode("200", "ok");
		private String value = null;
		private String desc = null;

		private SuccessCodeEnum(String v, String desc)
		{
			this.value = v;
			this.desc = desc;
		}

		@Override
		public String value()
		{
			return this.value;
		}

		@Override
		public String desc()
		{
			return this.desc;
		}
	}

	//	public enum FailEnum {
	//		private String value = null;
	//		private String desc = null;
	//
	//		private SuccessCodeEnum(String v, String desc) {
	//	        this.value = v;
	//	        this.desc = desc;
	//	    }
	//
	//		public String value() {
	//	        return this.value;
	//	    }
	//
	//		public String desc() {
	//	        return this.desc;
	//	    }
	//    }

	/**
	 * ev3c-2.0版本帧类型
	 */
	//	public static enum Ev3c2FrameCodeEnum {
	//		//通讯类：
	//		chargerRegister("A1", "注册充电设备地址-电桩发起"),
	//		chargerRegisterReturn("A2", "注册充电设备地址-服务器回复"),
	//		//
	//		ChargerQueryNull("10301102", "查询不到桩"),
	//		//	103013	电桩报文异常
	//		//02
	//		NetWorkTimeOut("10302100", "网络超时"),
	//		//03
	//		//103031	http参数错误
	//		HttpUnknownError("10303100", "http未知错误"),
	//		MissParam("10303101", "缺少参数字段"),
	//		ParamTypeError("10303102", "参数类型错误"),//数字123这种传了QWERTY
	//		ParamValueError("10303103", "参数数值错误"),//只能为1、2、3的传了4
	//		//103032	报文参数错误
	//		MessageUnknownError("10303200", "报文未知错误"),
	//		MessageMissParam("10303201", "报文缺少参数字段"),
	//		MessageParamTypeError("10303202", "报文参数类型错误"),
	//		MessageParamValueError("10303203", "报文参数数值错误"),
	//		//103033	redis异常
	//
	//		RedisQueryNull("10303301", "redis查询不到数据");
	//
	//		private String value = null;
	//		private String desc = null;
	//
	//		private ErrorCodeEnum(String v, String desc) {
	//	        this.value = v;
	//	        this.desc = desc;
	//	    }
	//
	//		public String value() {
	//	        return this.value;
	//	    }
	//
	//		public String desc() {
	//	        return this.desc;
	//	    }
	//	}

	/**
	 * 系统平台错误码枚举
	 * 错误定义规则：系统id（3位）+2位类型（业务异常、其它异常）+3位具体错误码。
	 * 业务类：01，网络超时类：02，其它异常：03
	 */
	public static enum ErrorCodeEnum implements EnumCodeValue
	{
		//01	
		//103011	站点异常		
		StationQueryException("10301101", "站点查询异常"),
		//103012	电桩异常
		ChargerQueryNull("10301102", "查询不到桩"),
		//	103013	电桩报文异常
		//02					
		NetWorkTimeOut("10302100", "网络超时"),
		//03	
		//103031	http参数错误
		HttpUnknownError("10303100", "http未知错误"),
		MissParam("10303101", "缺少参数字段"),
		ParamTypeError("10303102", "参数类型错误"),//数字123这种传了QWERTY
		ParamValueError("10303103", "参数数值错误"),//只能为1、2、3的传了4
		//103032	报文参数错误
		MessageUnknownError("10303200", "报文未知错误"),
		MessageMissParam("10303201", "报文缺少参数字段"),
		MessageParamTypeError("10303202", "报文参数类型错误"),
		MessageParamValueError("10303203", "报文参数数值错误"),
		MessageExecError("10303204", "报文操作失败"),
		//103033	redis异常

		RedisQueryNull("10303301", "redis查询不到数据"),
		//103034	Java类异常

		ThreadException("10303401", "线程类异常"),
		NullException("10303402", "空指针异常"),
		DataBaseConnectionException("10303403", "数据库连接异常"),
		RedisConnectionException("10303404", "redis库连接异常"),
		MiddleConnectionException("10303405", "中间件连接异常"),
		TeldConnectionException("10303406", "特来电连接异常"),
		ASConnectionException("10303407", "AS连接异常"),
		OSConnectionException("10303407", "OS连接异常"),
		MSConnectionException("10303407", "MS连接异常"),
		//103035	数据库异常
		SqlQueryException("10303501", "数据库查询异常"),
		SqlExecException("10303502", "数据库执行异常"),
		
		/** 10304* */
		BespeakResultChargerBespeaked("10304010", "该枪口已经被预约"),
		ConnectionResultChargerException("10304011", "该枪口已经被预约"),
		CancelBespeakResultNoBespeak("10304012", "当前用户没有预约该枪口,取消预约失败"),
		ChargeResultCloseChargerFail("10304014", "关闭充电失败"),
		StopChargeResultConnectionException("10304012", "桩出现故障"),
		BespeakResultExistNotPayOrder("10304015", "存在未支付的订单"),
		SystemServiceException("10304016","系统服务不可用"),
		ChargeResultDuplicateChargeInstruction("10304017", "该桩已经被他人开启了充电"),
		ChargeResultChargerBespeaked("10304018", "该枪口已经被预约"),
		/** 10305* 
		 * oms系统类异常 
		 *  */
		QueryEnterpriseUserNull("10305001", "查询企业用户不存在");
		
		private String value = null;
		private String desc = null;

		private ErrorCodeEnum(String v, String desc)
		{
			this.value = v;
			this.desc = desc;
		}

		@Override
		public String value()
		{
			return this.value;
		}

		@Override
		public String desc()
		{
			return this.desc;
		}
	}

	/**
	 * 报文响应码枚举 TODO
	 */
	public static enum MsgResponseCodeEnum implements EnumCodeValue
	{
		Normal("000000", "正常"),
		SysError("FFFFFF", "系统错误"),
		DecryptionError("FFFF01", "解密错误"),
		AccountError("FF0001", "注册账号错误"),
		PwdError("FF0002", "注册密码错误"),
		CityCodeError("FF0003", "城市代码不合法"),
		OperMerchantCodeError("FF0004", "运营商通讯编号不合法"),
		ChargerIdDuplicationError("FF0101", "注册设备地址重名"),
		DeviceTypeNotFound("FF0102", "设备类型未找到"),
		CommandFailed("FF0201", "命令执行失败"),
		ChargingGunNotInserted("FF0202", "充电枪未插好"),//可应用于回复指令“开启充电”
		EmergencyStopButtonPressed("FF0203", "急停按钮被按下，系统终止服务"),//可应用于回复所有控制指令
		UserCardNoAuth("FF0204", "该用户卡号无权进行该操作"),//可应用于回复开启/停止充电和开启/取消预约指令
		NoFrameCode("FF0301", "报文帧码未定义"),//可应用于回复指令“开启充电”
		MessageAnalysisAbnormal("FF0302", "报文解析异常"),
		ChargerIdVaildNotFound("FF0303", "设备地址不存在"),
		SerialNoNotFound("FF0304", "原流水号不存在");
		private String value = null;
		private String desc = null;

		private MsgResponseCodeEnum(String v, String desc)
		{
			this.value = v;
			this.desc = desc;
		}

		@Override
		public String value()
		{
			return this.value;
		}

		@Override
		public String desc()
		{
			return this.desc;
		}

		public static EnumCodeValue getMsgResponseCodeEnum(String v)
		{
			switch (v)
			{
				case "000000":
					return Normal;
				case "FFFFFF":
					return SysError;
				case "FFFF01":
					return DecryptionError;
				case "FF0001":
					return AccountError;
				case "FF0002":
					return PwdError;
				case "FF0003":
					return CityCodeError;
				case "FF0101":
					return ChargerIdDuplicationError;
				case "FF0201":
					return CommandFailed;
				case "FF0202":
					return ChargingGunNotInserted;
				case "FF0203":
					return EmergencyStopButtonPressed;
				case "FF0204":
					return UserCardNoAuth;
				case "FF0301":
					return NoFrameCode;
				case "FF0302":
					return MessageAnalysisAbnormal;
				case "FF0303":
					return ChargerIdVaildNotFound;
				case "FF0304":
					return SerialNoNotFound;
				default:
					return Normal;
			}
		}

	}

	public static final String kkkk = "00000000";

	/**
	 * 指令故障码枚举  ev3c 1.1 没有这个，1.2 在心跳报文中有这个，1.3在主动遥变中有这个
	 */
	public static enum MsgFaultCodeEnum implements EnumCodeValue
	{
		UnknownError("10303200", "报文未知错误"),
		MissParameter("10303201", "报文缺少参数字段"),
		ParamTypeError("10303202", "报文参数类型错误"),
		ParamValueError("10303203", "报文参数数值错误"),
		//以下是报文文档中定义的故障码
		Normal("00000000", "报文参数数值错误"),
		OtherFault("00000001", "其他故障"),
		EmergencyStop("00000002", "急停故障"),
		Ammeter("00000004", "电表故障"),
		Switches("00000008", "接触器故障"),
		cardReader("00000010", "读卡器故障"),
		OverTemperature("00000020", "内部过温故障"),
		Connector("00000040", "连接器故障"),
		Isolation("00000080", "绝缘故障"),
		OutputCurrentAbnormal("00000100", "输出电流异常"),
		OutputVoltageAbnormal("00000200", "输出电压异常"),
		ChargerModule("00000400", "充电机模块故障"),
		ChargerCommunication("00000800", "充电机通信故障"),
		BMSProhibitCharge("00001000", "BMS禁止充电"),
		InputVoltageAbnormal("00002000", "");

		private String value;
		private String desc;

		private MsgFaultCodeEnum(String v, String desc)
		{
			this.value = v;
			this.desc = desc;
		}

		@Override
		public String value()
		{
			return this.value;
		}

		@Override
		public String desc()
		{
			return this.desc;
		}

		public static MsgFaultCodeEnum getMsgFaultCodeEnum(String v)
		{
			switch (v)
			{
				case "10303200":
					return UnknownError;
				case "10303201":
					return MissParameter;
				case "10303202":
					return ParamTypeError;
				case "00000001":
					return OtherFault;
				case "00000002":
					return EmergencyStop;
				case "00000004":
					return Ammeter;
				case "00000008":
					return Switches;
				case "00000010":
					return cardReader;
				case "00000020":
					return OverTemperature;
				case "00000040":
					return Connector;
				case "00000080":
					return Isolation;
				case "00000100":
					return OutputCurrentAbnormal;
				case "00000200":
					return OutputVoltageAbnormal;
				case "00000400":
					return ChargerModule;
				case "00000800":
					return ChargerCommunication;
				case "00001000":
					return BMSProhibitCharge;
				case "00002000":
					return InputVoltageAbnormal;
				default:
					return Normal;
			}
		}

	}

	//	卡号编写规则：
	//	线上APP卡：188（卡丙3位）08（卡类型2位）0028（地区4位）1234567890（流水号10位）1（校验）
	//	线上第三方企业卡：188（卡丙3位）08（卡类型2位）9999（地区4位，写死成9999）1234567890（流水号10位）1（校验）
	//	线下卡（现金卡）：188（卡丙3位）06（卡类型2位）0028（地区4位）1234567890（流水号10位）1（校验）
	//	线下卡（身份认证卡）：188（卡丙3位）05（卡类型2位）0028（地区4位）1234567890（流水号10位）1（校验）

	/**
	 * 电桩状态突变--停止原因
	 */
	public static enum StopChargingReasonEnum implements EnumCodeValue
	{
		Normal("0X", "正常结束"),
		Backstage_Control("01", "后台远程控制正常结束"),
		Local_Control("02", "本地刷卡控制正常结束"),
		Satisfy_Condition("03", "满足预设停止条件正常结束"),
		Battery_Fullpower("04", "电池满电正常结束"),
		Equipment_Reason_Abnormal("1x", "设备原因异常结束"),
		Equipment_Powerdown_Abnormal("11", "设备掉电异常结束"),
		Emergency_Button_Abnormal("12", "急停按钮按下异常结束"),
		Charger_Over_Temperature("13", "充电机过温"),
		Charging_Connector_Abnormal("14", "充电连接器故障"),
		Charger_Inside_Abnormal("15", "充电机内部过温故障"),
		Power_Delivery_Abnormal("16", "所需电量不能传送"),
		ElectricCurrent_Matching_Abnormal("17", "电流不匹配"),
		Voltage_Abnormal("18", "电压异常"),
		Charger_Other_Reason("1F", "充电机其他原因"),
		BMS_Reason_Abnormal("2x", "BMS原因异常结束"),
		Insulation_Abnormal("21", "绝缘故障"),
		Connector_Over_Temperature("22", "连接器过温"),
		Connector_Abnormal("23", "连接器故障"),
		BMS_Original_Abnormal("24", "BMS原件故障"),
		Battery_Over_Temperature("25", "电池组温度过高"),
		VOltage_Relay_Abnnormal("26", "高压继电器故障"),
		Volyage_Testing_Abnormal("27", "电压检测故障"),
		ElectricCurrent_Over_large("28", "电流过大"),
		VOltage_Abnnormal("29", "电压异常"),
		BMS_Other_Reason("2F", "BMS其他原因");

		private String value = null;
		private String desc = null;

		private StopChargingReasonEnum(String v, String desc)
		{
			this.value = v;
			this.desc = desc;
		}

		@Override
		public String value()
		{
			return this.value;
		}

		@Override
		public String desc()
		{
			return this.desc;
		}

	}
	
	public static enum MsgCodeEnum
	{
		SUCCESS("200",1,"ok"),
		ERROR400("400",2,"operation error"),
		ERROR403("403",3,"forbidden operation"),		
		
		STATION_QUERY_ERROR("10301101",4,"站点查询异常"),
		CHARGER_QUERY_ERROR("10301201",5,"查询不到桩"),
		OTHER_LOGIN_ERROR("10301400",6,"用户验证失败"),
		OTHER_LOCK_ERROR("10301401",7,"用户被锁定"),
		OL_NO_POWER_ACCESS_ERROR("10301402",8,"没有权限访问该接口"),
		MS_RPC_ERROR("10301500",9,"MS_RPC系统服务错误"),
		SYSTEM_ERROR("10301501",10,"系统服务错误"),						
		OTHER_LOGIN_CHANNEL_NO_ERROR("10301600",11,"渠道号验证失败"),
		OL_REQUEST_PARAM_MISS_ERROR("10301700",12,"第三方token认证参数缺失"),
		OL_TOKEN_OUTTIME_ERROR("10301701",13,"第三方token已过期"),
		OL_TOKEN_AUTH_FAIL_ERROR("10301702",14,"第三方token认证失败"),
		
		SESSION_TIME_OUT("10302100",15,"网络超时"),		
		
		HTTP_UNKNOW_ERROR("10303100",16,"http未知错误"),
		REQUEST_PARAM_MISS_ERROR("10303101",17,"请求参数缺失"),
		HTTP_PARAM_TYPE_ERROR("10303102",18,"参数类型错误"),
		HTTP_PARAM_VALUE_ERROR("10303103",19,"参数数值错误"),
		MESSAGE_UNKNOW_ERROE("10303200",20,"报文未知错误"),
		MESSAGE_PARAM_MISS_ERROE("10303201",21,"报文缺少参数字段"),
		MESSAGE_PARAM_TYPE_ERROE("10303202",22,"报文参数类型错误"),
		MESSAGE_PARAM_VALUE_ERROE("10303203",23,"报文参数数值错误"),
		MESSAGE_PARAM_OPTION_ERROE("10303204",24,"报文操作失败"),
		JAVA_REDIS_QUERY_ERROE("10303301",25,"redis查询不到数据"),
		JAVA_THREAD_ERROE("10303401",26,"线程类异常"),
		JAVA_NULL_POINTER_ERROE("10303402",27,"空指针异常"),
		JAVA_DB_CONNECTION_ERROE("10303403",28,"数据库连接异常"),
		JAVA_REDIS_CONNECTION_ERROE("10303404",29,"redis库连接异常"),
		JAVA_MIDDLEWARE_CONNECTION_ERROE("10303405",30,"中间件连接异常"),
		JAVA_TELAIDIAN_CONNECTION_ERROE("10303406",31,"特来电连接异常"),
		JAVA_AS_CONNECTION_ERROE("10303407",32,"AS连接异常"),
		JAVA_OS_CONNECTION_ERROE("10303408",33,"OS连接异常"),
		JAVA_MS_CONNECTION_ERROE("10303409",34,"MS连接异常"),
		JAVA_DB_QUERY_ERROE("10303501",35,"数据库查询异常"),
		JAVA_DB_EXEC_ERROE("10303502",36,"数据库执行异常"),	
		
		AS_RPC_PARAM_FORMAT_ERROR("10306001",37,"请求参数格式错误"),
		AS_RPC_PARAM_TYPE_ERROR("10306002",38,"请求参数类型错误"),
		AS_RPC_PARAM_EMPTY_ERROR("10306003",39,"请求参数为空错误"),
		AS_RPC_SERVER_ERROR("10306004",40,"系统服务不可用"),
		AS_RPC_PARAM_SUCCESS("200",41,"成功"),    //
		OTHER_LOGIN_SUCCESS("10300200",42,"登录成功"),  //
		GET_RESERVATION_DISCOUNT_ERROR("10306005",37,"获取预约折扣信息失败");
		
		private int msgValue;
		private String msgCode;
		private String msgInfo;
		MsgCodeEnum(String msgCode,int msgValue,String msgInfo)
		{
			this.msgValue = msgValue;
			this.msgCode = msgCode;
			this.msgInfo  = msgInfo;
		}
		public String getMsgCode()
		{
			return msgCode;
		}
		public int getMsgValue()
		{
			return msgValue;
		}
		public void setMsgValue(int msgValue) {
			this.msgValue = msgValue;
		}
		public void setMsgCode(String msgCode) {
			this.msgCode = msgCode;
		}
		public String getMsgInfo() {
			return msgInfo;
		}
		public void setMsgInfo(String msgInfo) {
			this.msgInfo = msgInfo;
		}
		
	}
}